//
//  DaPeiCollectionViewCell.m
//  Cooking
//
//  Created by dlios on 15-10-9.
//  Copyright (c) 2015年 ZP.Y. All rights reserved.
//

#import "DaPeiCollectionViewCell.h"
#import "DaPeiModel.h"
#import "UIImageView+WebCache.h"


@interface DaPeiCollectionViewCell ()

@property(nonatomic ,retain)UIImageView *myImage;
@property(nonatomic ,retain)UILabel *nameLabel;
@property(nonatomic ,retain)UIImageView *myLockImage ;
@property(nonatomic ,copy) NSString *type;

@end


@implementation DaPeiCollectionViewCell



- (void)dealloc
{
    [_type release];
    [_myLockImage release];
    [_myImage release];
    [_nameLabel release];
    [super dealloc];
    
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creat];
    }
    return self;
}
-(void)creat
{
    self.myImage = [[UIImageView alloc]init];
    [self.contentView addSubview:_myImage];
    self.myImage.userInteractionEnabled = YES;
//    self.myImage.backgroundColor = [UIColor yellowColor];
    
    self.nameLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.nameLabel];
//    self.nameLabel.backgroundColor = [UIColor blueColor];
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.font = [UIFont systemFontOfSize:12];
    
    
    
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.myImage.frame = CGRectMake(0, 5, self.contentView.frame.size.width - 15, self.contentView.frame.size.height - 35);
    self.nameLabel.frame = CGRectMake(0, self.myImage.frame.size.height + 10 , self.contentView.frame.size.width - 15, 20);
    self.myLockImage.frame = CGRectMake(0, 5, self.contentView.frame.size.width - 15, self.contentView.frame.size.height - 35);

}

-(void)receveModel:(DaPeiModel *)model type:(NSString *)type
{
    [self.myImage sd_setImageWithURL:[NSURL URLWithString:model.image]placeholderImage:[UIImage imageNamed:@"zhanwei_01.png"]];
    self.nameLabel.text = model.text;
    self.type = @"";
    self.type = type;
    if ([_type isEqualToString:@"1"]) {
        [self.myLockImage removeFromSuperview];
        self.myLockImage = [[UIImageView alloc]init];
        [self.myImage addSubview:self.myLockImage];
        _myLockImage.image = [UIImage imageNamed:@"xuanZhong.png"];
        self.myLockImage.userInteractionEnabled = NO;
        self.myLockImage.frame = CGRectMake(0, 5, self.contentView.frame.size.width - 15, self.contentView.frame.size.height - 35);
        self.myLockImage.alpha = 0.5;
    }else{
        
        [self.myLockImage removeFromSuperview];
    }
    

}


@end
